import React from 'react'
import {textAlignAdapter} from '../utils'
import {ITableHeaderConfig} from "@/pages/SelfQuery/type";

interface IHeadCellProps {
  config: ITableHeaderConfig
}

function HeadCell(props: IHeadCellProps) {
  const {config, ...rest} = props
  if(!config){
    return {}
  }
  const {fontColor: color, fontFamily, fontStyle, fontWeight, justifyContent} = config.style
  const cellCssStyle: React.CSSProperties = {
    color,
    fontFamily,
    fontStyle,
    fontWeight: fontWeight as React.CSSProperties['fontWeight'],
    textAlign: textAlignAdapter(justifyContent)
  }
  return (
    <th style={cellCssStyle} {...rest} />
  )
}

export default HeadCell
